package config

import "go.uber.org/zap"

type Args map[string]string

func NewArgs() Args {
	return make(map[string]string)
}

func (this Args) GetRequired(name string) string {
	if name == "" {
		Logger.Panic("Args name is empty", zap.String("name", name))
	}

	value := this[name]
	if value == "" {
		Logger.Panic("Args value is empty", zap.String("name", name))
	}
	return value
}

func (this Args) Get(name string) string {
	if name == "" {
		Logger.Panic("Args name is empty", zap.String("name", name))
	}
	return this[name]
}

func (this Args) SetArgs(args Args) {
	for k, v := range args {
		this[k] = v
	}
}

func (this Args) GetArgs() Args {
	args := NewArgs()
	for k, v := range this {
		args[k] = v
	}
	return args
}

func (this Args) SetMap(args map[string]string) {
	for k, v := range args {
		this[k] = v
	}
}
